﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Data;
using TidyBlog.Data.Mapping;

namespace TidyBlog.Entity
{
    /// <summary>
    /// 用户实体类
    /// </summary>
    [Table(Name = "TidyBlog_Category", IsIgnoreRead = true)]
    public class Category
    {
        /// <summary>
        /// 分类编号
        /// </summary>
        [Column(IsPrimaryKey = true, IsDbGenerated = true)]
        public int CategoryId { get; set; }
        /// <summary>
        /// 分类名
        /// </summary>
        [Column(DataType = DbType.String, Length = 20), DisplayFormat(ConvertEmptyStringToNull = false)]
        public string CategoryName { get; set; }
        /// <summary>
        /// 分类关键字
        /// </summary>
        [Column(DataType = DbType.String, Length = 100), DisplayFormat(ConvertEmptyStringToNull = false)]
        public string Keywords { get; set; }
        /// <summary>
        /// 分类描述
        /// </summary>
        [Column(DataType = DbType.String, Length = 255), DisplayFormat(ConvertEmptyStringToNull = false)]
        public string Description { get; set; }
        /// <summary>
        /// 分类权重
        /// </summary>
        [Column(OrderBy = 1, OrderWay = 1)]
        public byte Weight { get; set; }
        /// <summary>
        /// 文章数，通过触发器更新 
        /// </summary>
        [Column(IsDbGenerated = true, IsUpdateIgnore = true)]
        public int PostCount { get; set; }


        /// <summary>
        /// 获取首页分类
        /// </summary>
        public static Category Home
        {
            get
            {
                return new Category()
                {
                    CategoryId = 0,
                    CategoryName = "首页"
                };
            }
        }
    }
}
